Skip to content

Fix GH-22167: reject out-of-range SOAP schema integers#22178

Open
LamentXU123 wants to merge 2 commits into
php:masterfrom
LamentXU123:bug-f-21
Open

Fix GH-22167: reject out-of-range SOAP schema integers#22178
LamentXU123 wants to merge 2 commits into
php:masterfrom
LamentXU123:bug-f-21

Conversation

@LamentXU123
Copy link
Copy Markdown
Contributor

@LamentXU123 LamentXU123 commented May 29, 2026

Fixed #22167

I also add logic to deal with numeric-strings. Now, both 2147483648 and 2147483648abc will not be accepted (also added tests). Other behaviors remain the same.

I don't sure if we can write the helper function in simpler ways using existing Zend API.

Comment thread ext/soap/php_schema.c
@devnexen
Copy link
Copy Markdown
Member

High level note ; I'd target master rather than 8.4. It's a correct change, but it turns input that currently parses (silently truncated by atoi) into a fatal SOAP-ERROR, so a WSDL
that works today could break on a patch release. That kind of stricter parsing belongs in the next minor where we can note it in UPGRADING; on a stable branch it's a
behavior change we'd rather avoid.

@LamentXU123
Copy link
Copy Markdown
Contributor Author

High level note ; I'd target master rather than 8.4. It's a correct change, but it turns input that currently parses (silently truncated by atoi) into a fatal SOAP-ERROR, so a WSDL that works today could break on a patch release. That kind of stricter parsing belongs in the next minor where we can note it in UPGRADING; on a stable branch it's a behavior change we'd rather avoid.

This is rather like a new feature than a bug fix, we have lots of similar fixes before (i.e. rejecting NUL bytes in some functions) targeting the master branch so this should be targeting it too.

@LamentXU123 LamentXU123 marked this pull request as draft May 29, 2026 10:18
@devnexen
Copy link
Copy Markdown
Member

take your time I ll (re)review it saturday at earliest.

Comment thread ext/soap/tests/bugs/gh22167.phpt
Comment thread ext/soap/php_schema.c
return node_is_equal_ex_one_of(node, name, ns);
}

static int schema_parse_int(const xmlChar *value, const char *name, bool allow_negative)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

workflow correct, can be possibly optimised/simplified like this

static int schema_parse_int(const xmlChar *value, const char *name, bool allow_negative)
  {
        const char *str = (const char *) value;
        zend_long lval = 0;
        int oflow_info = 0;
        uint8_t type = is_numeric_string_ex(str, strlen(str), &lval, NULL, true, &oflow_info, NULL);

        if (type != IS_LONG) {
                errno = 0;
                lval = ZEND_STRTOL(str, NULL, 10);
                if (oflow_info || (errno == ERANGE && lval != 0)) {
                        soap_error1(E_ERROR, "Parsing Schema: %s value is out of range", name);
                }
        }

        if (ZEND_LONG_EXCEEDS_INT(lval) || (!allow_negative && lval < 0)) {
                soap_error1(E_ERROR, "Parsing Schema: %s value is out of range", name);
        }

        return (int) lval;
  }

wdyt ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ext/soap silently accepts out-of-range XML Schema integer values due to atoi()

3 participants